﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BYS.AAPT.Common;
using LinqToExcel;
using LinqToExcel.Query;
using System.IO;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using EntityFramework.Extensions;

namespace BYS.XiAnComDept.BussLogic
{
    public class CompanyBll : BllBase
    {
        public CompanyBll(ComDeptContext db) : base(db) { }

        public List<Company> GetCompanies(string companyName = null)
        {
            if (string.IsNullOrEmpty(companyName))
            {
                return this.Db.Companies.ToList();
            }
            else
            {
                return this.Db.Companies.Where(x => x.CompanyName.Contains(companyName) || x.CompanyPreName.Contains(companyName)).ToList();
            }
        }

        public Company GetCompany(Guid comGuid)
        {
            return this.Db.Companies
                    .Include(x => x.Funds)
                    .Single(x => x.ComGuid == comGuid);
        }
    }
}
